-- =============================================
-- ��3��������@@Table_name��Ĵ洢����->�������ݵ����
-- Description:	�������ڵ���ÿ�����
-- =============================================     

CREATE PROCEDURE [dbo].[DelNode]  
(  
    @node_id int  
)  
AS  
declare @lft int  
declare @rgt int  
if exists(select Node_id from Tree where Node_id = @node_id)  
    begin  
        SET XACT_ABORT ON  
        BEGIN TRANSCTION  
            select @lft = Lft, @rgt = Rgt from Tree where Node_id = @node_id  
            delete from Tree where Lft >= @lft and Rgt <= @rgt  
            update Tree set Lft = Lft - (@rgt - @lft + 1) where Lft > @lft
            update Tree set Rgt = Rgt - (@rgt - @lft + 1) where Rgt > @rgt
            COMMIT TRANSACTION  
        SET XACT_ABORT OFF  
    end  
GO  